/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package task12;

import java.io.IOException;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import javax.swing.JOptionPane;

/**
 *
 * @author I
 */
public class Task12 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        InetAddress ia=null;
        String host=null;
        try {    
          //  host = "google.com";
            host = "173.194.32.40";
            if(host!=null){
                ia = InetAddress.getByName(host);
                scan(ia); 
            }
        }
        catch (UnknownHostException e) {
             System.err.println(e );
         }
    }
    public static void scan(final InetAddress remote) {     
        int port=0;
     
        
        for ( port = 0; port < 65536; port++) {
        try {
            Socket s = new Socket(remote,port);
            System.out.println("Сервер слушает на порту " + port);
            s.close();
        }
        catch (IOException ex) {
            System.out.println("Сервер не слушает на порту " + port);
        }
         }
     }
}
